const { User } = require('../../model/user');
module.exports = async (req,res)=>{
  //接收传入过来的id
  let id = req.query.id;
  //根据id查找用户
  let user = await User.findOne({_id: id});
  //如果查找到
  if(user){
    await User.findByIdAndDelete({_id: id});
    res.redirect('/admin/toUserList');
  }else{
    res.render('admin/userList',{
      message: '删除失败！！！'
    });
  }
}